package ren.kane.phoenix.util.reflect;

import java.lang.annotation.ElementType;

/**
 * @author renrk(1275) on 2019-08-14 9:58 AM
 **/
public class OtherTest {

    public static void main(String[] args) {
        Class cls = OtherTest.class;
        // 获取“类名”
        System.out.printf("%-50s:getSimpleName()=%s\n", cls, cls.getSimpleName());
        // 获取“完整类名”
        System.out.printf("%-50s:getName()=%s\n", cls, cls.getName());
        testOther();
    }

    private static void testOther() {
        class LocalA {

        }

        Class elementTypeCls = ElementType.class;
        System.out.printf("%-50s:isEnum()=%s\n", elementTypeCls, elementTypeCls.isEnum());

        Class clazz = OtherTest.class;
        OtherTest otherTest = new OtherTest();
        System.out.printf("%-50s:isInstance(obj)=%s\n", clazz, clazz.isInstance(otherTest));

        Class runCls = Runnable.class;
        System.out.printf("%-50s:isInterface()=%s\n", runCls, runCls.isInterface());

        // 局部内部类
        Class localCls = LocalA.class;
        System.out.printf("%-50s:isLocalClass()=%s\n", localCls, localCls.isLocalClass());

        // 成员内部类
        Class memCls = MemberB.class;
        System.out.printf("%-50s:isMemberClass()=%s\n", memCls, memCls.isMemberClass());

        // 类是不是“基本类型”。 基本类型，包括void和boolean、byte、char、short、int、long、float 和 double这几种类型
        Class primCls = int.class;
        System.out.printf("%-50s:isPrimitive()=%s\n", primCls, primCls.isPrimitive());

        // 类是不是“复合类”。 JVM中才会产生复合类，在java应用程序中不存在“复合类”！
        Class synCls = OtherTest.class;
        System.out.printf("%-50s:isSynthetic()=%s\n", synCls, synCls.isSynthetic());
    }

    class MemberB {
    }
}
